<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGuidesTable extends Migration
{

    protected $tableName = 'guides';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('标题');
            $table->unsignedInteger('cover')->comment('封面图片附件ID');
            $table->unsignedTinyInteger('level')->comment('课程级别');
            $table->json('metadata')->comment('发布的数据');
            $table->unsignedTinyInteger('is_published')->default(0)->comment('是否发布');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '精彩绘本'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
